home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 9.1 KB | 309 lines | [TEXT/MPS ] |
- ; Copyright © 1987-1990 by Apple Computer, Inc. All rights reserved.
- ; UDebug assembly language routines
-
- Blanks On
- String AsIs
- Case On
-
- Print Off
- Include 'Macros.a'
-
- Include 'IntEnv.a'
-
- LOAD 'ProgStrucMacs.d'
- LOAD 'FlowCtlMacs.d'
- Print On
-
- ;---------------------------------------------------------------------------------------------------
- DebugGlobals Record
- Export pCanEnterDebugger, pUDebugInitialized, pSegTable
- pCanEnterDebugger DC.W 0 ; Boolean: Debugger can be entered
- pUDebugInitialized DC.W 0 ; Boolean: if Trace unit is inited
- pSegTable DC.L 0 ; HandleListHandle
- EndR ; Too bad Pascal doesn't have initialization
-
- IF qDebug then
- Import DEBUGEXCEPTION ; in UDebug
-
- XDEBUGSYSERROR Proc Export ; SysError(errorCode: integer) [arg is in Reg D0]
- Clr.L -(SP) ; leave room for DEBUGException to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W D0,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGBUSERROR Proc Export ; Bus error
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #902,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGADDRERROR Proc Export ; Address error
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #903,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGILLINST Proc Export ; Illegal Instruction
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #904,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGZERODIV Proc Export ; Zero Divide
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #905,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGCHECK Proc Export ; Chk
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #906,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGOVERFLOW Proc Export ; TrapV
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #907,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- XDEBUGLINEF Proc Export ; Line 1111 traps
- Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- Move.W #911,-(SP) ; push errorCode On stack to call Pascal
- Jsr DEBUGEXCEPTION ; call a Pascal routine
- MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- Rts ; leave things just as they were when we started, And go to debugger
- EndProc
-
- ; Seg 'MADebugger' ; MUST BE IN Main SEGMENT
- ; .Proc XDEBUGNMI ; NMI (level 7)
- ; Clr.L -(SP) ; leave room for DEBUGEXCEPTION to leave our continuation address
- ; MoveM.L A0-A7/D0-D7,-(SP) ; save registers
- ; Move.W #900,-(SP) ; push errorCode On stack to call Pascal
- ; Jsr DEBUGEXCEPTION ; call a Pascal routine
- ; MoveM.L (SP)+,A0-A7/D0-D7 ; restore registers
- ; Rts ; leave things just as they were when we started, And go to debugger
- ; EndProc
-
- Endif
-
-
- ;---------------------------------------------------------------------------------------------------
- DevGlobals Record
- Export pDebugWindow, pFileName
- pDebugWindow DC.L 0 ; Reference to debug window. Contained here so it can be
- ; initialized to nil
- pPutProc DC.L 0 ; Address of the PASCAL Proc to Handle WriteLn requests
- ; Procedure DEVPUTTEXT(textBuf: Ptr, byteCount: longint);
- pGetProc DC.L 0 ; Address of the PASCAL Proc to Handle Read requests
- ; Function DEVGETTEXT(textBuf: Ptr, byteCount: longint): longint;
-
- pFileName DCB.B 256,0 ; FileName to intercept for console
- EndR
-
- ;-----------------------------------------------------------------------------------
- ;int DevFAccess(fName, cmd, arg)
- ; char *fName;
- ; int cmd;
- ; char *arg;
- ;{
- ;# define IgnoreCase false
- ;# define DiacritSens true
- ;
- ;/*
- ; if ((equalstring(fName, pFileName, false, true)))
- ;*/
- ; switch (cmd) {
- ; default:
- ; return(-1);
- ; case F_OPEN:
- ; return(0);
- ; }
- ;/*
- ; else
- ; return(-1);
- ;*/
- ;}
- F_OPEN EQU (('d'<<8)|00) ; for internal use only. Use only as directed.
- Seg 'Main'
- EXPORT FUNCTION DevFAccess(fName:L, cmd:L, arg:L):L,C
- BEGIN SAVE=D2/D3,WITH=DevGlobals
- Import EQUALSTRING, P2CSTRPROC, C2PSTRPROC ; library routines
- MOVE.L cmd(FP),D3
- Call C2PSTRPROC(fName(FP):L);
- LEA pFileName,A0
- Call EQUALSTRING:B(fName(FP):L, A0:L, #0:B, #1:B),D2
- Call P2CSTRPROC(fName(FP):L);
- IF# D2 NE.B #0 THEN.S
- Switch# D3
-
- Case#.S F_OPEN
- MOVEQ #0,D0
- Leave#.S
- Default#
- MOVEQ #-1,D0
-
- EndS#
- ELSE#.S
- MOVEQ #-1,D0
- ENDIF#
-
- RETURN
- EndF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevClose()
- ;{
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevClose:L,C
- BEGIN
- MOVEQ #0,D0
- Return
- EndF
-
-
- ;-----------------------------------------------------------------------------------
-
- Seg 'Main'
- EXPORT FUNCTION SETGETPROC(theGetProc:L):L
- BEGIN with=DevGlobals
- MOVE.L pGetProc,SETGETPROC(FP)
- MOVE.L theGetProc(FP), pGetProc
- Return
- EndF
-
- ;-----------------------------------------------------------------------------------
-
- Seg 'Main'
- EXPORT FUNCTION SETPUTPROC(thePutProc:L):L
- BEGIN with=DevGlobals
- MOVE.L pPutProc,SETPUTPROC(FP)
- MOVE.L thePutProc(FP), pPutProc
- Return
- EndF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevRead(iop)
- ; IOPort *iop;
- ;{
- ; int bytesRead;
- ;
- ; bytesRead = DevReadLn(iop->inQ.bufp, iop->inQ.count);
- ; iop->inQ.bufp += bytesRead;
- ; iop->inQ.count -= bytesRead;
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevRead(iop:L):L,C
- BEGIN with=DevGlobals,SAVE=D2/A2
-
- MOVE.L iop(FP),A2
-
- ; CALL (pGetProc):L($10(A2):L,$0E(A2):W),D0
- MOVE.L pGetProc, A0
- CLR.L -(SP) ;make room for function result
- MOVE.L $10(A2), -(SP)
- MOVE.W $0E(A2), -(SP)
- JSR (A0)
- MOVE.L (SP)+,D0
-
- ADD.L D0,$10(A2) ;add it to bufp
- SUB.L D0,$0C(A2) ;sub it from count
- MOVEQ #0,D0 ;Return value
- RETURN
- ENDF
-
-
- ;-----------------------------------------------------------------------------------
- ;int DevWrite(iop)
- ; IOPort *iop;
- ;{
- ; DevAddText(iop->inQ.bufp, iop->inQ.count);
- ;
- ; return(0);
- ;}
-
- Seg 'Main'
- EXPORT FUNCTION DevWrite(iop:L):L,C
- BEGIN with=DevGlobals,SAVE=D2/A2
-
- MOVE.L iop(FP),A2
-
- ; CALL (pPutProc)($10(A2):L,$0E(A2):W)
- MOVE.L pPutProc, A0
- MOVE.L $10(A2), -(SP)
- MOVE.W $0E(A2), -(SP)
- JSR (A0)
-
- CLR.L $0C(A2)
- MOVEQ #0,D0 ;Return Value
- RETURN
- ENDF
-
- ;-----------------------------------------------------------------------------------
- ;int DevIoctl(iop, cmd, arg)
- ; IOPort *iop;
- ; int cmd;
- ; char *arg;
- ;{
- ; switch (cmd) {
- ; case FIOINTERACTIVE:
- ; case TIOFLUSH:
- ; return(0);
- ; default:
- ; return(-1);
- ; }
- ;}
- Seg 'Main'
- EXPORT FUNCTION DevIoctl(iop:L, cmd:L, arg:L):L,C
- BEGIN
- Switch# cmd(FP)
-
- Case#.S FIOINTERACTIVE,TIOFLUSH
- MOVEQ #0,D0 ;Return Value
- Leave#.S
-
- Default#
- MOVEQ #-1,D0 ;Return Value
- EndS#
-
- RETURN
- EndF
-
- End
-